package com.tenghu.sbm.cus.controller;

import com.tenghu.sbm.cus.entity.CusBaseInfo;
import com.tenghu.sbm.cus.service.CusBaseInfoService;
import com.tenghu.sbm.rest.RestResponse;
import com.tenghu.sbm.utils.PageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户基础信息控制接口
 * @author Arvin
 * @date 2017/12/9 14:52
 */

@RestController
@RequestMapping(value = "/cus")
@Api(value = "客户基础信息控制接口",description = "处理客户基础信息")
public class CusBaseInfoController {

    @Autowired
    private CusBaseInfoService cusBaseInfoService;

    /**
     * 获取所有客户基础信息
     * @return
     */
    @RequestMapping(value = "/all/{page}/{size}",method = RequestMethod.POST)
    @ApiOperation(value = "获取所有客户信息",notes = "获取所有客户信息")
    RestResponse getAllCusBaseInfo(CusBaseInfo cusBaseInfo,
                                   @ApiParam(value = "当前页",name = "page",defaultValue = "1") @PathVariable("page") int currentPage,
                                   @ApiParam(value = "每页显示数量",defaultValue = "2") @PathVariable("size") int pageSize){
        return cusBaseInfoService.getAllCusBaseInfo(cusBaseInfo,currentPage,pageSize);
    }

    /**
     * 保存客户基础信息
     * @param cusBaseInfo 客户基础信息
     * @return
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "保存客户信息",notes = "保存客户信息")
    RestResponse saveCusBaseInfo(@ApiParam(value = "客户信息",name = "cusBaseInfo") CusBaseInfo cusBaseInfo){
        return cusBaseInfoService.saveCusBaseInfo(cusBaseInfo);
    }

    /**
     * 根据客户ID获取客户基础信息
     * @param cusId 客户ID
     * @return
     */
    @RequestMapping(value = "/get/{cusId}",method = RequestMethod.GET)
    @ApiOperation(value = "根据客户ID获取客户信息",notes = "根据客户ID获取客户信息")
    @ApiImplicitParam(value = "客户ID",name = "cusId",required = true,dataType = "String",paramType = "path")
    RestResponse getCusBaseInfoById(@PathVariable("cusId")  String cusId){
        return cusBaseInfoService.getCusBaseInfoById(cusId);
    }

    /**
     * 修改客户基础信息
     * @param cusBaseInfo 客户基础信息
     * @return
     */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ApiOperation(value = "更新客户信息",notes = "根据客户ID更新客户信息")
    RestResponse updateCusBaseInfo(@ApiParam(value = "客户信息",name = "cusBaseInfo") CusBaseInfo cusBaseInfo){
        return cusBaseInfoService.updateCusBaseInfo(cusBaseInfo);
    }

    /**
     * 根据客户ID删除客户信息
     * @param cusId 客户ID
     * @return
     */
    @RequestMapping(value = "/delete/{cusId}",method = RequestMethod.GET)
    @ApiOperation(value = "删除客户基础信息",notes = "根据客户ID删除基础信息")
    @ApiImplicitParam(value = "客户ID",name = "cusId",dataType = "String",paramType = "path",required = true)
    RestResponse deleteCusBaseInfo(@PathVariable(value = "cusId") String cusId){
        return cusBaseInfoService.deleteCusBaseInfo(cusId);
    }

    /**
     * 批量删除客户信息
     * @param cusIds 客户ID
     * @return
     */

    @RequestMapping(value = "/delete/batch/{cusIds}",method = RequestMethod.GET)
    @ApiOperation(value = "批量删除客户基础信息",notes = "根据客户ID批量删除基础信息")
    @ApiImplicitParam(value = "客户ID",name = "cusIds",dataType = "String",paramType = "path",required = true)
    RestResponse deleteBatchCusBaseInfo(@PathVariable(value = "cusIds") String cusIds){
        return cusBaseInfoService.deleteBatchCusBaseInfo(cusIds.split(","));
    }
}
